package com.shop.admin.service.impl;

import com.shop.admin.service.IIndexService;
import com.shop.common.util.*;
import org.springframework.stereotype.Service;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 主页服务实现类
 */
@Service
public class IndexServiceImpl implements IIndexService {
    /**
     * 公共配置
     *
     * @author fzr
     * @return Map<String, Object>
     */
    @Override
    public Map<String, Object> config() {
        Map<String, String> website   = ConfigUtils.get("website");
        String copyright = ConfigUtils.get("website", "copyright", "");

        Map<String, Object> map = new LinkedHashMap<>();
        map.put("webName", website.getOrDefault("name", ""));
        map.put("webLogo", UrlUtils.toAbsoluteUrl(website.getOrDefault("logo", "")));
        map.put("webFavicon", UrlUtils.toAbsoluteUrl(website.getOrDefault("favicon", "")));
        map.put("webBackdrop", UrlUtils.toAbsoluteUrl(website.getOrDefault("backdrop", "")));
        map.put("copyright", ListUtils.stringToListAsMapStr(copyright));

        return map;
    }

}
